# import numpy as np  
# import matplotlib.pyplot as plt  
# from mpl_toolkits.mplot3d import Axes3D  
  
# # 创建一个3D坐标轴  
# fig = plt.figure()  
# ax = fig.add_subplot(111, projection='3d')  
  
# # 绘制三维散点图  
# x = np.random.rand(50)  
# y = np.random.rand(50)  
# z = np.random.rand(50)  
# ax.scatter(x, y, z)  
  
# # 绘制三维曲面图  
# x = np.linspace(-5, 5, 100)  
# y = np.linspace(-5, 5, 100)  
# x, y = np.meshgrid(x, y)  
# z = np.sin(np.sqrt(x**2 + y**2))  
# ax.plot_surface(x, y, z, rstride=1, cstride=1, cmap='viridis', edgecolor='none')  
  
# # 设置坐标轴标签  
# ax.set_xlabel('X Label')  
# ax.set_ylabel('Y Label')  
# ax.set_zlabel('Z Label')  
  
# # 显示图像  
# plt.show()



import numpy as np  
import matplotlib.pyplot as plt  
from mpl_toolkits.mplot3d import Axes3D  
  
# 创建一个新的图形  
fig = plt.figure()  
  
# 添加一个3D子图  
ax = fig.add_subplot(111, projection='3d')  
  
# 定义x和y的范围  
x = np.linspace(-2, 2, 100)  
y = np.linspace(-2, 2, 100)  
  
# 创建网格  
X, Y = np.meshgrid(x, y)  
  
# 计算z的值  
Z = X**2 + Y**2 - 2*X*Y  
  
# 绘制曲面  
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap='viridis', edgecolor='none')  
  
# 设置坐标轴标签  
ax.set_xlabel('X')  
ax.set_ylabel('Y')  
ax.set_zlabel('Z')  
  
# # 设置标题  
# ax.set_title('3D plot of x**2 + y**2 - 2*x*y')  
  
# 显示图像  
plt.show()
